//
//  VideoPlayer.m
//  XRmenu
//
//  Created by gaomz on 11-3-23.
//  Copyright 2011 E0571. All rights reserved.
//

#import "VideoPlayer.h"


@implementation VideoPlayer
@synthesize player;
@synthesize url;

- (id)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code.
		player = [[MPMoviePlayerController alloc] init];
		
		//[[NSNotificationCenter defaultCenter]
//		 addObserver:self
//		 selector:@selector(movieFinishedCallback:)                                                
//		 name:MPMoviePlayerPlaybackDidFinishNotification
//		 object:player];
		
		player.view.frame = CGRectMake(0.0, 0.0, frame.size.width, frame.size.height);	
		[self addSubview:player.view];
		
				
    }
    return self;
}


-(void)playVideo
{
	if (url) {
		//---play movie---
		[player play];   

	}
	
}

-(void)setPlayerUrl:(NSString *)playUrl
{
	url=playUrl;
	player.contentURL = [NSURL fileURLWithPath:url];
}



//- (void) movieFinishedCallback:(NSNotification*) aNotification {
//    MPMoviePlayerController *moviePlayer = [aNotification object];
//    [[NSNotificationCenter defaultCenter]
//	 removeObserver:self
//	 name:MPMoviePlayerPlaybackDidFinishNotification
//	 object:moviePlayer];   
//	[moviePlayer.view removeFromSuperview];
//	[player release];
//}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code.
}
*/

- (void)dealloc {
	[player stop];
	[player release];
    [super dealloc];
}


@end
